/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.springtree.spectrum.visa.persistence;

import co.springtree.spectrum.visa.persistence.dao.CommandDAO;
import co.springtree.spectrum.visa.persistence.dao.CommandRuleDAO;
import co.springtree.spectrum.visa.persistence.dao.RuleDAO;
import co.springtree.spectrum.visa.persistence.entities.CommandDTO;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.log4j.Logger;

public class PersistenceFacade implements Serializable {
    private static PersistenceFacade instance;
    private static final long serialVersionUID = 4134771351415236980L;
    private static Logger logger = Logger.getRootLogger();
    private CommandDAO commandDAO;
    private RuleDAO ruleDAO;
    private CommandRuleDAO commandRuleDAO;
    
    private PersistenceFacade() {
        this.commandDAO = new CommandDAO();
        this.ruleDAO = new RuleDAO();
        this.commandRuleDAO = new CommandRuleDAO();
        logger.debug("Facade Persistence Initialized");
    }
    
    public static PersistenceFacade getInstance(){
        if(instance==null){
            instance = new PersistenceFacade();
        }
        return instance;
    }

    public CommandDAO getCommandDAO() throws SQLException {
        return commandDAO;
    }
 

   
    /**
     * Inicializa las tablas del sistema
     *
     * @throws SQLException
     */
    public void initialize() throws Exception {
        commandDAO.createTable(true);
        ruleDAO.createTable(true);
        commandRuleDAO.createTable(true);
    }
}
